package cc.lj.internal.core.model;

import com.github.pagehelper.IPage;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.Min;

/**
 * 分页查询入参实体
 * @param <T>
 */
@Data
@Accessors(chain = true)
public class PageParam<T> implements IPage {
    //  description = "页码", defaultValue =  1
    private Integer pageNum = 1;

    //  description = "页数", defaultValue = 15
    private Integer pageSize = 15;

    //  description = "排序", example = "id desc"
    private String orderBy;

    //  description = "参数"
    @Valid
    private T param;

    public PageParam<T> setOrderBy(String orderBy) {
        this.orderBy = orderBy; // 此处可自行过滤非法字符，防止sql注入
        return this;
    }
}
